cc.Class({
    extends: cc.Component,

    properties: {
        SelectUI: cc.Node,
        seconds: cc.Label,
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        var animSelectUI = this.SelectUI.getComponent(cc.Animation);
        animSelectUI.play('selectUI_load');
        this.seconds.string = '10';
    },

    addSeconds(){
        var sec = parseInt(this.seconds.string);
        if (sec < 99){
            sec += 1;
            this.seconds.string = sec;
        }
    },

    delSeconds(){
        var sec = parseInt(this.seconds.string);
        if (sec > 1){
            sec -= 1;
            this.seconds.string = sec;
        }
    },

    ChangeToGameOnDefault: function () {
        // cc.log('to default scene game on')
        var anim = this.SelectUI.getComponent(cc.Animation);
        var animState = anim.getAnimationState('button_default_gameon');
        if (animState.isPlaying == false) {
            anim.play('button_default_gameon');
        }
    },

    ChangeToGameOnDefaultReal: function () {
        cc.props = {initTimer: 8};
        cc.director.loadScene('gameon');
    },

    ChangeToGameOnCustom: function () {
        var sec = parseInt(this.seconds.string);
        var anim = this.SelectUI.getComponent(cc.Animation);
        var animState = anim.getAnimationState('button_custom_gameon');
        if (animState.isPlaying == false) {
            anim.play('button_custom_gameon');
        }
    },

    ChangeToGameOnCustomReal: function () {
        var sec = parseInt(this.seconds.string);
        cc.props = {initTimer: sec};
        cc.director.loadScene('gameon');
    },
    // update (dt) {},
});
